package com.sunny.ynhz.adapter;

import android.content.Intent;
import android.support.annotation.Nullable;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sunny.ynhz.R;
import com.sunny.ynhz.bean.IndexProblemListBean;
import com.sunny.ynhz.ui.daily.news.PatrolNewsActivity;
import com.sunny.ynhz.utils.TimeFormatUtils;

import java.util.List;

/**
 * Created by luao on 2017/8/22.
 */

public class PatrolNewsAdapter extends BaseQuickAdapter<IndexProblemListBean.DataBean, BaseViewHolder> {
    public PatrolNewsAdapter(@Nullable List<IndexProblemListBean.DataBean> data) {
        super(R.layout.item_patrol_news, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, final IndexProblemListBean.DataBean item) {
        helper.setText(R.id.title, item.getName());
        helper.setText(R.id.time, TimeFormatUtils.timeStamp2Date(item.getTm(), "[MM-dd HH:mm]"));

        helper.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, PatrolNewsActivity.class);
                intent.putExtra("type", item.getType());
                intent.putExtra("id", item.getId());
                intent.putExtra("url",item.getUrl());
                mContext.startActivity(intent);
            }
        });
    }


}
